<template>
  <div class="selfname">
    <header-tab @saveName="saveName"  msg="昵称" isPhone="9"></header-tab>
   
     
      <div class="result">
        <group>
          <x-textarea placeholder="昵称" show-counter :rows="1"  :max="10" v-model="name"></x-textarea>
        </group>
      </div>
    
  </div>
</template>

<script>
import HeaderTab from '@/components/HeaderTab'
import { XTextarea,Group } from 'vux'
 import {memberInfoEdit} from '@/api/index'
 import {
    setAllToken,
    getAllToken
} from '@/utils/auth';
export default {
  name: 'feedSuccess',
  components: {
    HeaderTab,XTextarea,Group
  },
  data () {
    return {
     name:'',
     infoForm:{}
    }
  },
  mounted() {
    this.infoForm = JSON.parse(sessionStorage.getItem("myselfInfo"));
  },
  methods: {
    saveName(){
      this.handleEdit();
    },
    handleEdit(){
      if(!this.name){this.$vux.toast.text('昵称不能为空','middle');return}
      // this.$router.push("/feedBack/success");
      let para = {
        "memberNo" :this.$store.state.user.memberNo || getAllToken("memberNo"),                //类型：String  必有字段  备注：广告位置编码
        'memberName':this.name,
        'avatar':this.infoForm.avatar,
        'birthday':this.infoForm.birthday,
        'gender':this.infoForm.gender,
        'cityNo':this.infoForm.cityNo,
      }
      memberInfoEdit(para).then((res)=>{
          if(res.data.code == '000'){
            this.$vux.toast.text("保存成功",'middle');
            this.$router.go(-1);
          }else{
            this.$vux.toast.show({
              text: '网络异常，稍后重试'
            })
          }
      }).catch((err)=>{
          // alert(err);
      });
    },
    backHome(){
      // this.$store.dispatch('updateTabbarIndex', {"tabbarIndex": 0})
      this.$router.push("/");
    },
   
    
  },
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style  lang="less">
    @import '../../styles/common.less';
    .selfname{
        position:fixed;
        top:0;
        left:0;
        background:#F8FAFD;
        width:100%;
        height:100%;
        .weui-cell{
          width:100%;
          padding:0;
          text-indent:2em;
        }
        .weui-cells:before,.weui-cells:after{
          border:none;
        }
        .vux-no-group-title{
          margin:0;
        }
        .weui-cell__bd,.weui-cells{
           background:#F8FAFD;
        }
        .weui-textarea{
          height:14.93vw;
          line-height:14.93vw;
          background:#fff;
          padding:0 2vw ;
        }

    }
    
</style>
